package com.microservices.cloud.service.impl;

import com.microservices.cloud.dao.StorageDao;
import com.microservices.cloud.service.StorageService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class StorageServiceImpl implements StorageService {

    @Resource
    private StorageDao storageDao;


    @Override
    public Integer updateStorage(Long productId, Integer count) {
        log.info("------------>storage-service中扣减库存开始");
        Integer result = storageDao.updateStorage(productId, count);
        log.info("------------>storage-service中扣减库存结束");
        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return result;
    }
}
